#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int mod=998244353,inf=0x3f3f3f3f3f3f3f3f;
const int N=2e5+10,M=2e5+10;
int n;
int a[N],b[N];
int checkA()
{
	for ( int i = 1 ; i <= n ; i++ )
		if(b[i]!=1)return 0;
	return 1;
}
void subA()
{
	int mn=inf;
	for ( int i = 1 ; i <= n ; i++ )
		mn=min(mn,a[i]);
	for ( int i = 1 ; i <= n ; i++ )
		cout << mn-1 << endl;
}
int checkB()
{
	for ( int i = 1 ; i <= n ; i++ )
		if(b[i]!=1e9)return 0;
	return 1;
}
set<int>st;
multiset<int>st2;
int tag[N],c[N],m;
vector<int>vec[N];
void add(int x)
{
	auto it=st.insert(x).first;
	auto l=--it;
	it++;
	auto r=++it;
	it--;
	int rt=*r,lf=*l;
//	cout << "ins " << x << " " << lf << " " << rt << endl;
	st2.erase(st2.find(-(rt-lf-1)));
	st2.insert(-(rt-x-1));
//	cout << "insq " << rt-x-1 << endl;
	st2.insert(-(x-lf-1));
//	cout << "insq " << x-lf-1 << endl;
}
void subB()
{
	for ( int i = 1 ; i <= n ; i++ )
		c[i]=a[i];
	sort(c+1,c+1+n);
	m=unique(c+1,c+1+n)-c-1;
//	cout << "debug" << endl;
	for ( int i = 1 ; i <= n ; i++ )
		a[i]=lower_bound(c+1,c+1+m,a[i])-c;
//	for ( int i = 1 ; i <= n ; i++ )
//		cout << a[i] << " ";
//	cout << endl;
	for ( int i = 1 ; i <= n ; i++ )
		vec[a[i]].push_back(i);
//	cout << "debug " << endl;
	st2.insert(-n);
	st.insert(0),st.insert(n+1);
	for ( int i = 1 ; i <= m ; i++ )
	{
		for ( auto j:vec[i] )add(j);
		int maxlen=-(*st2.begin());
//		for ( auto j:st2 )
//			cout << -j << " ";
//		cout << endl;
		tag[maxlen]=i;
	}
	for ( int i = n-1 ; i >= 1 ; i-- )
		tag[i]=max(tag[i],tag[i+1]);
	for ( int i = 1 ; i <= n ; i++ )
		cout << (int)1e9-(c[tag[i]+1]) << endl;
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("min.in","r",stdin);
	freopen("min.out","w",stdout);
	cin >>n;
	for ( int i = 1 ; i <= n ; i++ )
		cin >> a[i];
	for ( int i = 1 ; i <= n ; i++ )
		cin >> b[i];
	if(checkA())return subA(),0;
	if(checkB())return subB(),0;
	deque<int>q1,q2;
	for ( int len = 1 ; len <= n ; len++ )
	{
		q1.clear(),q2.clear();
		int mn=0;
		for ( int i = 1 ; i <= len ; i++ )
		{
			while(!q1.empty()&&a[q1.back()]>=a[i])
				q1.pop_back();
			while(!q2.empty()&&b[q2.back()]>=b[i])
				q2.pop_back();
			q1.push_back(i);
			q2.push_back(i);
		}
		mn=abs(a[q1.front()]-b[q2.front()]);
		for ( int i = 2 ; i+len-1 <= n ; i++ )
		{
			if(q1.front()<i)q1.pop_front();
			if(q2.front()<i)q2.pop_front();
			while(!q1.empty()&&a[q1.back()]>=a[i+len-1])
				q1.pop_back();
			while(!q2.empty()&&b[q2.back()]>=b[i+len-1])
				q2.pop_back();
			q1.push_back(i+len-1);
			q2.push_back(i+len-1);
			mn=min(mn,abs(a[q1.front()]-b[q2.front()]));
		}
		cout << mn << endl;
	}
	return 0;
}//64
/*
3
1 3 2
1000000000 1000000000 1000000000
*/
